<?php
	header('content-type:text/html;charset="utf-8"');

	require_once "conn.php";
	require_once "je.php";
	
	//$uname=$_REQUEST['usnm'];
	//$upswd=$_REQUEST['pswd'];
	$json=file_get_contents("php://input");
	$data = json_decode($json,true);
	
	$uname=$data['usnm'];
	$upswd=$data['pswd'];
	
	if(isset($uname)){

		$conn=new mysqli($hn,$un,$pw,$db);
		
		if($conn->connect_error) die($conn->connect_error);
		
		$query="select * from users where `username`='{$uname}' and `password`='{$upswd}'";
		$conn->query('set names utf8');
		$result=$conn->query($query);

		if(!$result)  die($conn->error);
		
		$results=array();
		if($conn->affected_rows<1){
			$results["code"]=0;
			$results["mes"]="用户名或密码错误";
		}
		else{
			$results["code"]=1;
			$results["mes"]="登录成功";
			$results["user"]=$uname;
		}
		$s=my_json_encode($results);
		
		echo $s;

		$result->close();
		$conn->close();
	}
?>